<?php
class NewMailInfoAction extends SzAbstractAction {
    protected $paramTypes = array(
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_INT,
    );

    /**
     * @param $userId
     * @param $reqTime
     * @return SzResponse
     */
    public function execute($userId,$pageIndex,$reqTime) {
        if (!GameService::get()->verifySysUnlock($userId, GameConst::FUNC_NEW_MAIL)) {
            return $this->buildResponse(false);
        }
        GameService::get()->validateMultiRequestTimeDelta($userId, $reqTime);
        $data = NewMailService::get()->mailInfo($userId,$pageIndex,$reqTime);
        if ($data) {
            $mail = $data['mail'];
            $page = $data['page'];
        } else {
            $mail = array();
            $page = 0;
        }
        return $this->buildResponse(
           array(
               'mail' => $mail,
               'page' => $page
           )
        );
    }
}